import { ref } from 'vue'
import { defineStore } from 'pinia'
export const UseStore = defineStore('store', () => {
    const index = ref(1);
    const topic = ref("设备控制")
    function increment() {
        if (index.value >= 2) {
            return
        }
        index.value++;
    };
    function decrease() {
        if (index.value <= 1) {
            return
        }
        index.value--;
    };
    function changeTopic(text) {
        topic.value = text
    }
    return { index, topic, increment, decrease, changeTopic };
},
    {
        persist: [
            {
              key: "useIndex",
              paths: ['index'],
              storage: localStorage,
            },
            {
             key: "custom-topic",
              paths: ['topic'],
              storage: localStorage,
            },
          ],
    })